//
//  MBProgressHUD+CP.m
//  CPBaseXCode
//
//  Created by cp on 2024/9/23.
//

#import "MBProgressHUD+CP.h"

@implementation MBProgressHUD (CP)
//隐藏加载动画的方法
+ (void)hideHUDForView:(UIView *)view{
    if (view == nil) view = (UIView*)[UIApplication sharedApplication].delegate.window;
    [self hideHUDForView:view animated:YES];
}
+ (void)hideHUD{
    [self hideHUDForView:nil];
    
}
+ (void)hideHUDview:(UIView *)view{
    [self hideHUDForView:view animated:YES];
}
+ (void)showMessageText:(NSString *)text  toView:(UIView *)view afterDelay:(NSTimeInterval)time
{
    if (view == nil) view = (UIView*)[UIApplication sharedApplication].delegate.window;
    MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.detailsLabel.text = text;
//    hud.label.font=sFONT(28);
    hud.detailsLabel.font = PFReFONT(15);
    hud.mode = MBProgressHUDModeText;
//    hud.animationType = MBProgressHUDAnimationZoomIn;
    hud.detailsLabel.textColor=[UIColor whiteColor];
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.5];
//    hud.removeFromSuperViewOnHide = YES;
    [hud hideAnimated:YES afterDelay:time];
    
}
+ (void)showtoView:(UIView *)view
{
   if (view == nil) view = (UIView*)[UIApplication sharedApplication].delegate.window;
    MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    
    hud.margin = 7;//修改该值，可以修改加载框大小
//    hud.mode = MBProgressHUDModeIndeterminate;
    //背景颜色
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = [UIColor colorWithWhite:0.f alpha:.2f];
    
//    //设置菊花框为白色 activityIndicatorColor
    //hud.activityIndicatorColor = [UIColor colorWithRed:246/255.0 green:8/255.0 blue:142/255.0 alpha:1];
    //hud.opacity = 1;
//    hud.square = YES;//等宽高
//    hud.margin = 7;//修改该值，可以修改加载框大小
//    hud.removeFromSuperViewOnHide = YES;
//    [hud showAnimated:YES];

}
/** 加载菊花 */
+ (void)showtoViewsame:(UIView *)view Text:(NSString *)text{
    if (view == nil) view = (UIView*)[UIApplication sharedApplication].delegate.window;
    MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.label.text = text;
    //背景颜色
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = [UIColor colorWithWhite:0.f alpha:.2f];
     hud.label.textColor=[UIColor whiteColor];
}

@end
